<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use kartik\file\FileInput;
use kartik\select2\Select2;
use yii\web\JsExpression;
use app\common\Functions;

/* @var $this yii\web\View */
/* @var $model \yii2mod\rbac\models\BizRuleModel */
/* @var $form ActiveForm */
?>

<section class="content document-modify-uesr-form">
    <div class="box box-primary col-sm-6">
        <div class="box-body box-profile">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">×</span></button>
                <h4 class="modal-title"><?php echo Html::encode($this->title);?></h4>
            </div>
            <div class="row">

                 <div class="box-body">

                    <?php $form = ActiveForm::begin(); ?>

                        <?php




                        echo  $form->field($model, 'id',['labelOptions'=>['style'=>'display:none']])->hiddenInput(['value' => $model->id]);

                        echo $form->field($model, "state")->label('修改订单状态!')->dropDownList($orderStates);


                        $orderStaffIDStyles = [];
                        //  Yii::trace("@@@@@@@@@-----------@@@@@@@@@@@");
                      //  if ($model->staffName)
                      //  {

                            //Yii::trace($model->orderStaffName);
                     //       $orderStaffIDStyles['initValueText'] = $model->staffName;
                            // $parentStyles['value'] = $model->parentProdName;
                     //   }

                        $orderStaffIDStyles['options'] = ['placeholder' => '请选择 ...'];

                        if ($model->staffName)
                        {
                            $orderStaffIDStyles['initValueText']  = $model->staffName;
                        }

                        $orderStaffIDStyles['pluginOptions'] = [
                            'placeholder' => '查询 ...',
                            'allowClear' => true,

                            'minimumInputLength' => 1,
                            'language' => [
                                'errorLoading' => new JsExpression("function () { return '稍等...'; }"),
                            ],
                            'ajax' => [
                                'url' => '/prod/prodinst/seachorderstaff',
                                'dataType' => 'json',
                                'data' => new JsExpression('function(params) { return {q:params.term}; }')
                            ],
                            'escapeMarkup' => new JsExpression('function (markup) { return markup; }'),
                            'templateResult' => new JsExpression('function(res) { 
            
            return res.text; }'),



                            'templateSelection' => new JsExpression('function (res) { 
                      
                     
                    return res.text; }')];
                        echo $form->field($model, 'staff_id')->label( '订单追踪人')->widget(Select2::classname(), $orderStaffIDStyles);


                        echo  $form->field($model, 'remark')->label( '请务必填写跟进记录！')->textarea(['maxlength' => 256,'rows'=>3]);
                        ?>

                         <div class="modal-footer">

                             <?php echo Html::a(Yii::t('region', 'Cancel'), '', ['class' => 'btn btn-default','data-dismiss'=>'modal']); ?>
                             <?php echo Html::submitButton($model->getIsNewRecord() ? Yii::t('region', 'Create') : Yii::t('region', 'Update'), [
                                 'class' => $model->getIsNewRecord() ? 'btn btn-success' : 'btn btn-primary', ]); ?>
                         </div>


                    <?php ActiveForm::end(); ?>

                </div>
            </div>
        </div>
    </div>
</section>
